package com.yzd.learnjava.generics;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ArrayBlockingQueue;

public class GenericListDemo {
	public static void main(String[] args) {
//		List<Fruit> list1 = new ArrayList<Apple>();
		
		List<? extends Fruit> list2 = new ArrayList<Apple>();
		//list2.add(new Object());
		//list2.add(new Apple());
		//list2.add(new Fruit());
		list2.add(null);
		
//		Apple apple = list2.get(0);
		Fruit fruit = list2.get(1);
		
		
		List<? super Apple> list3 = new ArrayList<Fruit>();
//		List<? super Apple> list3 = new ArrayList<Apple>();
		list3.add(new Apple());
		//list3.add(new Fruit());
		//list3.add(new Orange());
		list3.add(new Jotange());
		
		List<Apple> list4 = new ArrayList<Apple>();
		Apple apple = list4.get(0);
		fruit = list4.get(1);
		
//		apple = list3.get(0);
//		fruit = list3.get(0);
		Object object = list3.get(0);
		apple = (Apple)list3.get(0);
		fruit = (Apple)list3.get(0);
		
		
		List<?> list5 = new ArrayList<Apple>();
		//list5.add(new Object());
//		list5.add(new Apple());
		
		Object obj = list5.get(0);
		
		List list6 = new ArrayList<Apple>();
		list6.add(new Object());
		
		//TreeSet set = new TreeSet();
//		ArrayBlockingQueue queue = new ArrayBlockingQueue(20);
		
		TreeMap map = new TreeMap();
	}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
	
	
}

class Fruit{}
class Apple extends Fruit{}
class Orange extends Fruit{}
class Jotange extends Apple{}
